﻿Public Class frmListaPrecio

    Dim ds As DataSet = Nothing

    Sub New(dt As DataSet)

        ' Llamada necesaria para el diseñador.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        Me.ds = dt
    End Sub

    Private Sub frmListaPrecio_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        cargarListaPrecios()
    End Sub

    Sub cargarListaPrecios()
        dgvPrecios.DataSource = ds.Tables(0)

        If ds.Tables(0).Rows.Count <> 0 Then
            dgvPrecios.Rows(0).Selected = False
        End If
    End Sub

    Private Sub dgvPrecios_CellClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvPrecios.CellClick
        Dim f As Integer = e.RowIndex

        If f > -1 Then
            'frmPedido.txtListaPrecio.Text = dgvPrecios.Item("Column1", f).Value.ToString.Trim
            'frmPedido.lblListaPrecio.Text = dgvPrecios.Item("Column2", f).Value.ToString.Trim
            frmMenu.formDocumento.txtListaPrecio.Text = dgvPrecios.Item("Column1", f).Value.ToString.Trim
            DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub dgvPrecios_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dgvPrecios.KeyDown
        If e.KeyValue = Keys.Enter Then
            frmMenu.formDocumento.txtListaPrecio.Text = dgvPrecios.Rows(dgvPrecios.CurrentRow.Index).Cells("Column1").Value
            DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub dgvPrecios_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dgvPrecios.KeyUp
        If (e.KeyCode = Keys.Escape) Then
            Me.Close()
        End If
    End Sub

End Class